// miniprogram/pages/consumption/detail/detail.js
const db = wx.cloud.database()
const _ = db.command
Page({
  data: {
    formData: {},
    id: null
  },
  onLoad: function (options) {
    wx.showLoading({
      title: '正在加载...'
    })
    this.setData({
      id: options.id
    })
  },
  onShow: function () {
    this.initData()
  },
  initData: function () {
    
    db.collection('consume').where({
      _id: this.data.id
    }).get({
      success: (res) => {
        wx.hideLoading()
        let data = res.data[0]
        data.money = parseFloat(data.money).toFixed(2)
        this.setData({
          formData: data
        })
      }
    })
  },
  goEdit: function (e) {
    wx.navigateTo({
      url: '../edit/edit?data=' + JSON.stringify(this.data.formData)
    })
  }
})